/*
 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "assembly-parser.h"

namespace ark::pandasm {
// NOLINTNEXTLINE(readability-function-size)
inline std::string OperandTypePrint(ark::pandasm::Opcode op) {
    switch (op) {
% Panda::instructions.group_by(&:mnemonic).each do |mnemonic, group|
%    insn = group.first
%    operands = insn.operands
%    properties = insn.properties
        case Opcode::<%= group.first.asm_token%>: {
%    operands_list = operands.map do |op|
%        if op.reg?
%            'reg'
%        elsif op.imm?
%            properties.include?('jump') ? 'label' : 'imm'
%        elsif op.id?
%            if properties.include?('type_id')
%                'type'
%            elsif properties.include?('string_id')
%                'string'
%            elsif properties.include?('method_id')
%                'call'
%            else
%                'id'
%            end
%        end
%    end.join('_')
%    operands_list = 'none' if operands_list == ''
                return "<%= operands_list%>";
        };
%end
        default:
            return "undefined";
    }
}
} // namespace ark::pandasm
